import request from "@/utils/request.ts";
import type {
    allRoleResponseInter,
    loginDataInter,
    loginResponseInter,
    logoutInter, setRoleInter,
    userInfoResponseInter
} from "@/api/user/type.ts";
import type {ResponseInter} from "@/api/commonInterFace.ts";

enum API {
    login_url = '/admin/acl/index/login',
    userInfo_url = '/admin/acl/index/info',
    logout_url = '/admin/acl/index/logout',
    allRole_url = '/admin/acl/user/toAssign',
    setRole_url = '/admin/acl/user/doAssignRole',
    // 删除某一个账号
    removeUser_url = '/admin/acl/user/remove',
    // 批量删除账号
    removeUserBatch_url = '/admin/acl/user/batchRemove',
}

export const reqLogin = (data: loginDataInter) => request.post<string, loginResponseInter>(API.login_url, data)
export const reqUserInfo = () => request.get<string, userInfoResponseInter>(API.userInfo_url)
export const reqLogout = () => request.post<string, logoutInter>(API.logout_url)
// 获取所有角色
export const reqAllRole = (id: number) => request.get<string, allRoleResponseInter>(`${API.allRole_url}/${id}`)
// 设置角色
export const reqSetUserRole = (data: setRoleInter) => request.post<string, ResponseInter>(API.setRole_url, data)
// 删除某一个账号
export const reqRemoveUser = (id: number) => request.delete<string, ResponseInter>(`${API.removeUser_url}/${id}`)
// 批量删除账号
export const reqRemoveUserBatch = (idList: number[]) => request.delete<string, ResponseInter>(API.removeUserBatch_url, {data: idList})
